ngl: Improve the glyph front cache
authorMatthias Clasen <mclasen@redhat.com>
Fri, 19 Mar 2021 18:30:19 +0000 (14:30 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Fri, 19 Mar 2021 18:32:03 +0000 (14:32 -0400)
The effectiveness of the front cache is limited by
subpixel positioning making it very likely that we
will meet the same glyph in  different x phases inside
a single line of text.

Factoring the xphase into the front cache key makes things
better. For the string eeeeeeeeeeeeeeeeeee

before: 0% front cache hits
after: >90% front cache hits

gsk/ngl/gsknglglyphlibraryprivate.h

index f48ae6e585a8f9328fa5d03b90417b15c2560cc7..c44068dd5091adf1db1660a37bd7239517e6e46b 100644 (file)
@@ -91,7 +91,7 @@ gsk_ngl_glyph_library_lookup_or_add (GskNglGlyphLibrary      *self,
                                      const GskNglGlyphValue **out_value)
 {
   GskNglTextureAtlasEntry *entry;
-  guint front_index = key->glyph & 0xFF;
+  guint front_index = ((key->glyph << 2) | key->xshift) & 0xFF;
 
   if (memcmp (key, &self->front[front_index], sizeof *key) == 0)
     {